<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/dtree.css">
<link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/font/dtreefont.css">
  <style type="text/css">
	.layui-form .layui-form-item{
		width:90%;
	}
	</style>
</head>
<body style="margin-top: 10px">
<form class="layui-form" lay-filter="myform">
<input type="hidden" name="id">
<input type="hidden" name="orgId" id="orgId" th:value="${session.MEORG.id}">
<div class="layui-form-item">
		    <label class="layui-form-label">文件</label>
		    <div class="layui-upload">
		    <div class="layui-input-inline">
		        <button type="button" class="layui-btn" id="test1">上传</button>
		    </div>
		    <label class="layui-form-label">存储名称</label>
		    <div class="layui-input-inline">
       	 	   <input type="text" name="repoName" id="repoName" readonly="readonly" class="layui-input">
		    </div>
		    </div>
   		</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">版本名称</label>
		    <div class="layui-input-inline">
		      <input type="text" name="versionName" autocomplete="off" class="layui-input">
		    </div>
		    <label class="layui-form-label">版本编号</label>
		    <div class="layui-input-inline">
		      <input type="text" name="versionCode" autocomplete="off" class="layui-input">
		    </div>
	  	</div>
	  	<div class="layui-form-item">
	  		<label class="layui-form-label">文件大小</label>
		    <div class="layui-input-inline">
		      <input type="text" name="fileSize" lay-verify="fileSize" placeholder="系统计算" autocomplete="off" class="layui-input">
		    </div>
		    <label class="layui-form-label">风格</label>
		    <div class="layui-input-inline">
		      <select name="styleCode" id="styleCode"></select>
		    </div>
	  	</div>
		<div class="layui-form-item">
		    <label class="layui-form-label">下载地址</label>
    		<div class="layui-input-inline" style="width:410px!important">
      			<input id="url" name="url" type="text" readonly="readonly" class="layui-input">
    		</div>
    		
	  	</div>
	  	<div class="layui-form-item">
		    <label class="layui-form-label">更新说明</label>
		    <div class="layui-input-block" style="width:450px!important;">
		      <textarea id="expression" name="expression" class="layui-textarea"></textarea>
		    </div>
		</div>
	  	<div class="layui-form-item">
		    <label class="layui-form-label">登记人</label>
		    <div class="layui-input-inline">
       	 	   <input type="text" name="createUserName" id="createUserName" lay-filter="createUserName" th:value="${session.me.name}" readonly="readonly" class="layui-input">
       	 	   <input type="hidden" name="createUserId" id="createUserId" th:value="${session.me.id}">
		    </div>
		    <label class="layui-form-label">登记时间</label>
		    <div class="layui-input-inline">
       	 	   <input type="text" name="createTime" id="createTime" lay-filter="createTime" th:value="${currentTime}" readonly="readonly" class="layui-input">
		    </div>
	  	</div>
	  	
<button id="submitBtn" class="layui-btn" style="display:none" lay-submit lay-filter="submitme">保存</button>
</form>
<script src="layuiadmin/plugins/xm-select/xm-select.js"></script>
 <script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
var id=/*[[${id}]]*/ 
var orgId=/*[[${orgId}]]*/ 
var myorgId=/*[[${session.MEORG.id}]]*/

/*]]>*/
</script>
<script th:inline="none">
layui.extend({ 
	dtree: '{/}layuiadmin/plugins/dtree/dtree/dtree'
});
var appId = "";
if(!id){
	appId = snowId();
}else{
	appId = id;
}
layui.use(['element','table','dtree','form','upload','laydate'], function(){
    var form = layui.form,
    element = layui.element,
    laydate = layui.laydate,
    upload = layui.upload,
    dtree = layui.dtree;
    createSelect("app-style-code","styleCode",form);
    var uploadInst = upload.render({
		elem: '#test1'
		,url: 'appVersion/upload'
		,accept: 'file'
		  // ,acceptMime: 'application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
		 ,ext: 'apk'
		,before: function(obj){
			this.data.id = appId;
		}
		,done: function(res){
			var entity = getEntityInfo(appId,"appVersion/getById");
	    	form.val('myform',entity);
	    	layer.alert("上传成功");
		}
		,error: function(){
		    var demoText = $('#demoText');
		    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
		    demoText.find('.demo-reload').on('click', function(){
		        uploadInst.upload();
		    });
		}
	});
    function loadData(){
		var entity = getEntityInfo(id,"appVersion/getById");
    	form.val('myform',entity);
    }
    if(id){
    	loadData();
    }
	form.on('submit(submitme)', function(data){
		var values = {id:appId};
		$(":input").each(function(i,v){
			if(v.name)
			values[v.name] = v.value;
		})
		var url = 'appVersion/save';
		$.ajax({
			url: url,
			data: values,
			type:'POST',
			dataType:'JSON',
			success: function(ret){
				let win = getTabWin();
				win.loadGrid("main-table");
				layer.msg("保存成功");
				var index = top.layer.getFrameIndex(window.name); 
				top.layer.close(index); 
			}
		})
		return false; 
	});
});
</script>
</body>
</html>